Skip to content

fix(client): honor request options and redirect semantics - #36

Open
rupayon123 wants to merge 7 commits into
kavix:mainfrom
rupayon123:contribution/http-redirect-correctness-20260911
Open

rupayon123 wants to merge 7 commits into
kavix:mainfrom
rupayon123:contribution/http-redirect-correctness-20260911

Conversation

@rupayon123

@rupayon123 rupayon123 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem and change

HTTP request options were not consistently honored: custom Host headers were ignored, mixed-case HTTP schemes were treated as bare hostnames, timeout annotations discarded the original error, and each redirect restarted the timeout. A fixed 10-second header wait also overrode longer or disabled timeouts. The redirect logic also followed non-redirect 3xx statuses and changed HEAD to GET on 303.

Apply Host through Request.Host, recognize schemes case-insensitively, wrap timeout causes, and use a deadline shared across the redirect chain and body read. Follow only 301/302/303/307/308 and retain HEAD on 303. Remove the separate fixed response-header deadline so the configured request timeout governs the header wait. Deadline cleanup transfers to the returned body so successful responses remain readable.

Validation

Six regression groups failed before their respective fixes. Local HTTP-server tests cover non-redirect status codes, HEAD redirects, virtual hosts, mixed-case schemes, total redirect timeout and deferred body consumption. An 11-second local server verifies both a 30-second timeout and timeout zero; both cases failed at 10 seconds before the fix. Error-chain assertions verify errors.Is/errors.As.

After each fix: env -u NO_COLOR go test ./..., go vet ./..., formatting and diff checks pass. golangci-lint is unavailable locally. Remote CI is tracked separately. Prepared with AI assistance.

@rupayon123

Copy link
Copy Markdown
Contributor Author

Additional fixes pushed to this branch:

  • 61dd9b4: Release per-request HTTP transport resources after body close.

Full Go tests, go vet and build pass. A local HTTP server verifies that closing the response body closes the otherwise stranded idle connection. HTTP/3 cleanup is wired but has not been tested against a live HTTP/3 endpoint. Today's changes have no new findings under golangci-lint v2.13.2 using a migrated copy of the repository configuration. This is a scoped lint result: a full CLI-branch scan still reports 93 findings outside today's changes; the legacy v1 linter cannot read the installed Go 1.27 export format.

Prepared with AI assistance. Changes are submitted for review; this is not a claim of maintainer approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant